package com.mingqijia.gassafety.console.controller;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.webserver.request.InformRecordRequest;
import com.mingqijia.gassafety.webserver.request.WarningRecordInfoRequest;
import com.mingqijia.gassafety.webserver.response.RecordDetailInfoResponse;
import com.mingqijia.gassafety.webserver.response.RecordDetailListResponse;
import com.mingqijia.gassafety.webserver.response.RecordResponse;
import com.mingqijia.gassafety.webserver.service.RunningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/business/running/record/")
@Api("运行报告通知记录")
public class RunningRecordController {

    @Autowired
    private RunningRecordService service;

    @ApiOperation("通知列表")
    @RequestMapping(value = "list", method = RequestMethod.POST)
    public CommonResponse<PageUtil<RecordResponse>> recordList(@RequestBody InformRecordRequest request){
        PageUtil<RecordResponse> list = service.getList(request);
        return CommonResponse.success(list);
    }

    @ApiOperation("详情列表")
    @RequestMapping(value = "detail/list", method = RequestMethod.POST)
    public CommonResponse<PageUtil<RecordDetailListResponse>> detailList(@RequestBody @Valid WarningRecordInfoRequest request){
        PageUtil<RecordDetailListResponse> list = service.getDetailList(request);
        return CommonResponse.success(list);
    }

    @ApiOperation("详情统计数据")
    @RequestMapping(value = "detail/info", method = RequestMethod.POST)
    public CommonResponse<RecordDetailInfoResponse> detailInfo(@RequestBody @Valid WarningRecordInfoRequest request){
        RecordDetailInfoResponse response = service.getDetailInfo(request);
        return CommonResponse.success(response);
    }
}
